import React from 'react'
import { Form,Table, Icon, Tag, Modal, Select } from 'antd'
import { DropOption } from 'components'
import styles from './List.less'
const Option = Select.Option
const confirm = Modal.confirm

class ModalSelect extends React.Component {
 constructor(props) {
    super(props);
    this.state = {
      current: 0,
      dep:'',
    };
 }
	details(text,record,a){
		const {onDetails} = this.props
		let params ={
			organizationId:this.state.dep,
			departmentId:record.departmentId,
			state:a
		}
//		console.log(params)
		onDetails(params)
	}
	handleChange(value) {
	  this.setState({dep:value})
	  const {onGroup} =  this.props
	  onGroup(value)
	}
	render(){
		const { loading, list1, pagination1, onPageChange, list2,showDetail,onGroup,list,listDetais,department1} = this.props;
//		console.log(department1)
//		console.log(list)
		const depChild = [];
		for (let i = 0; i < department1.length; i++) {
		  depChild.push(<Option key={department1[i].id}>{department1[i].name}</Option>);
		}
		const columns = [{
		  title: '部门',
		  dataIndex: 'departmentName',
		},{
		  title: '未归档文档',
		  className: 'column-money',
		  dataIndex: 'unfiledCount',
		  render: (text,record) =>{
		  		if(record.departmentId){
                    return <a href="#" onClick={this.details.bind(this,text,record,0)}>[{text}]</a>
                }
		  		return <span>{text}</span>
		  },
		},{
		  title: '已归档文档',
		  dataIndex: 'filedCount',
		  render: (text,record) =>{
		  		if(record.departmentId){
                    return <a href="#" onClick={this.details.bind(this,text,record,1)}>[{text}]</a>
                }
		  		return <span>{text}</span>
		  },
		},{
		  title: '历史文档',
		  dataIndex: 'historyCount',
		  render: (text,record) =>{
		  		if(record.departmentId){
                    return <a href="#" onClick={this.details.bind(this,text,record,2)}>[{text}]</a>
                }
		  		return <span>{text}</span>
		  },
		},{
		  title: '文档总数',
		  dataIndex: 'sums',
		  render: (text,record) =>{
		  		if(record.departmentId){
                    return <a href="#" onClick={this.details.bind(this,text,record,"")}>[{text}]</a>
                }
		  		return <span>{text}</span>
		  },
		}
//		,{
//		  title: '操作',
//		  dataIndex: 'operation',
//		  render: text => <a href="#">{text}</a>,
//		}
		];

		return (
		     <div>
		     	  <span>组织机构:</span>
		     	  <Select style={{marginLeft:20,width:150}} placeholder="请选择组织机构" onChange={this.handleChange.bind(this)}>
                    	{depChild}
                  </Select>
				  <Table
				  	style={{marginTop:20}}
				    columns={columns}
				    dataSource={list}
				    bordered
				  />
		      </div>
	  	)
	}
  

}

export default Form.create()(ModalSelect)
